eslint-plugin-promise
Enforce best practices for JavaScript promises.
Installation
You'll first need to install ESLint:
npm install eslint --save-dev
Next, install eslint-plugin-promise
:
npm install eslint-plugin-promise --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must
also install eslint-plugin-promise
globally.
Usage
Add promise
to the plugins section of your .eslintrc.json
configuration
file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["promise"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"promise/always-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/avoid-new": "warn",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "warn",
"promise/valid-params": "warn"
}
}
or start with the recommended rule set:
{
"extends": ["plugin:promise/recommended"]
}
Rules
💼 Configurations enabled in.
⚠️ Configurations set to warn in.
🚫 Configurations disabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the
--fix
CLI option.
Maintainers
License